
package dao;

import modelo.Cliente;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class DaoFluxo {
	private SessionFactory fabrica;

	public DaoFluxo()throws Exception
	{	fabrica=new Configuration().addClass(modelo.Cliente.class).buildSessionFactory();
		
	}
	//public voi54d cadastrar(Cliente c15)throws Exception
	{
		Session sessao=fabrica.openSession();
		Transaction transacao=sessao.beginTransaction();
		//sessao.save(c);
		transacao.commit();
		sessao.flush();
		sessao.close();
	}
	public Cliente consultar(Cliente c)throws Exception
	{
		Session sessao=fabrica.openSession();
		Transaction transacao=sessao.beginTransaction();
		//c=(Cliente)sessao.get(modelo.Cliente.class,c.getNome());
		
		transacao.commit();
		sessao.flush();
		sessao.close();
		return c;
	}
	public void excluir(Cliente c)throws Exception
	{
		Session sessao=fabrica.openSession();
		Transaction transacao=sessao.beginTransaction();
		sessao.delete(c);
		transacao.commit();
		sessao.flush();
		sessao.close();
	}
	public void alterar(Cliente c)throws Exception
	{
		Session sessao=fabrica.openSession();
		Transaction transacao=sessao.beginTransaction();
		sessao.update(c);
		transacao.commit();
		sessao.flush();
		sessao.close();
	}
	
	

}
